package June;
import java.util.Scanner;
public class Test_7_5 {
    public static void main(String[] args) {
        //在一个字符串数组中进行查找
        Scanner myScanner = new Scanner(System.in);
        String[] name = {"北京", "上海", "广州", "深圳"};
        System.out.print("请输入你要查找的字符：");
        String findName = myScanner.next();
        //定义一个标识数，如果它未改变，说明没有找到输入的字符
        int index = -1;
        for (int i = 0; i < name.length; i++) {
            if (findName.equals(name[i])) {
                System.out.println("找到了");
                System.out.println("它的下标为：" + i);
                index = 1;
                break;
            }
        }
        if (index == -1) {
            System.out.println("没有找到该字符");
        }
    }
}
